package com.example.cathouse;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import java.util.List;

public class CatViewModel extends AndroidViewModel {
    private CatRepository catRepository;

    public CatViewModel(@NonNull Application application) {
        super(application);
        catRepository = new CatRepository(application);
    }

    public LiveData<List<Cat>> getAllCatsLive() {
        return catRepository.getAllCatsLive();
    }

    public void insertCats(Cat... cats) {
        Cat cat = new Cat("小橘子", "三花", "母", "健康", "已绝育", "吃东西的时候可以随便摸", "花花的", "猫霸");
        Cat cat1 = new Cat("花花", "三花", "母", "健康", "已绝育", "吃东西的时候可以随便摸", "花花的", "猫霸");
        catRepository.insertCats(cat, cat1);
    }

    public void updateCats(Cat... cats) {
        catRepository.updateCats(cats);
    }

    public void deleteCats(Cat... cats) {
        catRepository.deleteCats(cats);
    }

    public void deleteAllCats() {
        catRepository.deleteAllCats();
    }

    public LiveData<Cat> getCat(int id) {
        return catRepository.getCat(id);
    }

    public LiveData<List<Cat>> findCatsWithPattern(String pattern) {
        return catRepository.findCatWithPattern(pattern);
    }

}
